package fractal.action;

import fractal.app.AppDefine;
import fractal.view.AppView;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/** Class make action for application */
public final class AppAction implements ActionListener {

	private String actionName;
	private AppView appView;

	/** constructor arguments: action name */
	public AppAction(String actionName) {
		this.actionName = actionName;
	}

	/** constructor arguments: action name, application view */
	public AppAction(String actionName, AppView appView) {
		this.actionName = actionName;
		this.appView = appView;
	}

	@Override
	/** action listener method */
	public void actionPerformed(ActionEvent aEvent) {
		try {
			if (this.actionName.equals(AppDefine.STARTNEW)) {
				this.appView.setWindow(AppDefine.STARTNEW);

			} else if (this.actionName.equals(AppDefine.FRACTAL1)) {
				this.appView.setWindow(AppDefine.FRACTAL1);

			} else if (this.actionName.equals(AppDefine.FRACTAL2)) {
				this.appView.setWindow(AppDefine.FRACTAL2);

			} else if (this.actionName.equals(AppDefine.SKINDEF)) {
				this.appView.setSkin(AppDefine.SKINDEF);

			} else if (this.actionName.equals(AppDefine.SKINSYS)) {
				this.appView.setSkin(AppDefine.SKINSYS);

			} else if (this.actionName.equals(AppDefine.DEFAULT)) {
				this.appView.setDefoult();

			} else if (this.actionName.equals(AppDefine.HOMEPAGE)) {
				this.appView.messageBox("Strona www", 1);

			} else if (this.actionName.equals(AppDefine.ABOUT)) {
				this.appView.messageBox("Project " + AppDefine.APPNAME, 1);

			} else if (this.actionName.equals(AppDefine.RESTART)) {
				System.exit(0);

			} else if (this.actionName.equals(AppDefine.EXIT)) {
				System.exit(0);

			}
		} catch (Exception ex) {
			System.err.println("Menu action error!\n" + ex.toString());
		}
	}
}
